#ifndef SYMBOL_MODEL_H
#define SYMBOL_MODEL_H

#include <QAbstractTableModel>
#include <QVector>
#include "Symbol.h"
class LanguageModel;

class SymbolModel : public QAbstractTableModel
{
    Q_OBJECT
    
public:

    explicit SymbolModel(QObject *parent = 0);
    
    virtual int rowCount( const QModelIndex & index ) const
    {
        if( index.isValid() )
        {
            return 0;
        }
        
        return symbolTable.size();
    }
    
    virtual int columnCount( const QModelIndex & index ) const
    {
        Q_UNUSED( index );
        
        return 4;
    }
    
    bool isModified() const { return modified; }
    
    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    
    virtual bool insertRow( int row, const QModelIndex & parent = QModelIndex() );
    virtual bool removeRow( int row, const QModelIndex & parent = QModelIndex() );
    
    void initializeModel( int index, const QVector<Symbol> & symbol_table );
    const QVector<Symbol> & getSymbolTable() const { return symbolTable; }
    
    void setCurrentLanguage( LanguageModel * model )
    {
        currentLanguageModel = model;
    }
    
signals:

    void contentsChanged();
    
private:

    void setModified();

    QVector<Symbol> symbolTable;
    int currentIndex; //next available unique index
    bool modified;
    LanguageModel * currentLanguageModel;

};

#endif
